//! Copyright (c) M5Stack. All rights reserved.

//! Licensed under the MIT license. See LICENSE file in the project root for full license information.
/**
 * \par Copyright (C), 2016-2017, M5Stack
 * \class M5StickC
 * \brief   M5StickC library.
 * @file    M5StickC.h
 * @author  M5Stack
 * @version V0.0.6
 * @date    2019/04/08
 * @brief   Header for M5StickC.cpp module
 *
 * \par Description
 * This file is a drive for M5StickC core.
 *
 * \par Method List:
 *    
 *  System:
 *    M5.begin();
 * 
 *  LCD:
        M5.Lcd.drawPixel(int16_t x, int16_t y, uint16_t color);
 * *
 * \par History:
 * <pre>
 * `<Author>`         `<Time>`        `<Version>`        `<Descr>`
 * Yang Zhou         2019/04/08         0.0.6          Rebuild the new.
 * </pre>
 *
 */

#ifndef _M5STICKC_H_
#define _M5STICKC_H_

#if defined(ESP32)

#include <Arduino.h>
#include <Wire.h>
#include <SPI.h>

#include "M5Display.h"
#include "AXP192.h"

#include "utility/Config.h"
#include "utility/MPU6886.h"
#include "utility/Button.h"
#include "utility/CommUtil.h"

#include "RTC.h"
#include "IMU.h"

class M5StickC {
	
	typedef void(*Button_FuncCallBack_t)(Button*, int);

 public:
    M5StickC();
	void begin(bool LCDEnable=true, bool PowerEnable=true, bool SerialEnable=true);
	void EventAttach(Button_FuncCallBack_t function);
    void update();
	
    //!LCD
    M5Display Lcd = M5Display();
	CommUtil I2C = CommUtil();
    AXP192 Axp = AXP192();
    RTC Rtc;
    IMU Imu;
    MPU6886 Mpu6886;
	Button BtHOME;
    Button BtSELE;

 private:
    bool isInited;
};


extern M5StickC M5;
#define m5 M5
#define lcd Lcd
#define axp Axp
#define imu Imu
#define IMU Imu
#define MPU6886 Mpu6886
#define mpu6886 Mpu6886

#else
#error “This library only supports boards with ESP32 processor.”	
#endif

#endif